package com.itlong.cloud.controller.nginx;

import com.itlong.cloud.POJO.VO.MessageVO;
import com.itlong.cloud.enumerate.ecode.BaseErrorCodeEnum;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * <desc>
 *   运维和SDK服务保持心跳Controller
 * </desc>
 *
 * @createDate 2020/12/30
 */
@RestController
@RequestMapping
public class NginxController {


    /**
     * <desc>
     *      运维和SDK服务保持心跳调用
     * <desc/>
     *
     * @param request
     * @return
     * @author Juguang.S
     * @createDate 2020/12/30
     */

    @RequestMapping(value = "/sdk/nginx/heartbeat")
    public Object service(HttpServletRequest request) {
        return new MessageVO(BaseErrorCodeEnum.SUCCESS.getErrorCode());
    }

    /**
     * <desc>
     *      测试
     * <desc/>
     *
     * @param request
     * @return
     * @author Juguang.S
     * @createDate 2021/02/02
     */

    @RequestMapping(value = "/sdk/test")
    public void test(HttpServletRequest request) {
        AtomicInteger atomicInteger = new AtomicInteger();
        while (true) {
            new Thread(() -> {
                int num = atomicInteger.incrementAndGet();
                System.out.println(num);
                try {
                    Thread.sleep(60*60*1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }).start();
        }
    }


}
